﻿using Health.Code;
using Health.Domain;
using Health.Infrastructure.Interface;
using Health.WebAPI.Read.Applicant.Command;
using MediatR;

namespace Health.WebAPI.Read.Applicant.CommandHandler
{
    /// <summary>
    /// 就医指南列表
    /// </summary>
    public class MedicalGuideShowCommandHandler : IRequestHandler<MedicalGuideShowCommand, APIRestl<List<MedicalGuide>>>
    {
        IBaseRepository<MedicalGuide> medicalRep;

        public MedicalGuideShowCommandHandler(IBaseRepository<MedicalGuide> medicalRep)
        {
            this.medicalRep = medicalRep;
        }

        public Task<APIRestl<List<MedicalGuide>>> Handle(MedicalGuideShowCommand request, CancellationToken cancellationToken)
        {
            APIRestl<List<MedicalGuide>> restl = new APIRestl<List<MedicalGuide>>();
            restl.code = APIEnum.显示成功;
            restl.mes = APIEnum.显示成功.ToString();

            var list = medicalRep.GetAll();

            restl.data = list.ToList();

            return Task.FromResult(restl);
        }
    }
}
